<?php
namespace application\datatypes;
use application\datatypes\DataType;
use application\utilities\Utility;
use application\system\Permalink;
class ID extends DataType {
	public static $name = 'ID';
	public static $fields = array(array('columnType'=>'BIGINT(20)'));
	
	public static function validate($field, $data, $results) {
		$id = $data['content_id'];
		$results['db_fields']['content_id'] = $id;
		
		return $results;
	}
	
	public static function display($formElements) {
		if($formElements) {
			echo $formElements['elements']['element'];
		}
	}
	
	public static function build($field, $data) {
		$value = $data[$field->cf_column];
		if($value) {
			$formElements = array('column'=>$field->cf_column, 'data_type'=>$field->cf_data_type, 'elements'=>array(
							'element'=>
								sprintf('<input type="hidden" name="%1$s" id="%1$s" value="%2$s"/>', $field->cf_column, $value)
							
			));
			return $formElements;
		}
		else
			return FALSE;
	
	}
	
	public static function editForm($field) {
		?>
		<div class="box-content">
			You can't edit an automatic field.
		</div>
			<?php
	}
	
	public static function prepareData($field, $data) {
		return $data[$field->cf_column];
	}
	
}
?>